"use strict";

import * as React from 'react'
import {iconProps} from "./index";

const {View, Text, StyleSheet,TouchableOpacity} = require('react-native');
import createIconSet from 'react-native-vector-icons/lib/create-icon-set';
import MyBadge from "./MyBadge";
const glyphMap = require('./iconfont.json');

const IconSet = createIconSet( glyphMap , 'iconfont' , 'iconfont.ttf' );
export default class MyIcon extends React.Component<iconProps, any> {
    static defaultProps = {
        size:20,
        color:'#ccc',
        name:'',
        onPress:null,
        badgeNumber:0,
        inIconFont:true,
    };

    render() {

        const {
            style,
            badgeNumber,
        } = this.props;
        if(this.props.onPress){
            return   (
                <TouchableOpacity onPress={this.props.onPress} style={style}>
                    <MyBadge number={badgeNumber}>
                        <IconSet {...this.props} style={style}/>
                    </MyBadge>
                </TouchableOpacity>
            )
        }
        return (
            <MyBadge number={badgeNumber}>
                <IconSet {...this.props} style={style}/>
            </MyBadge>

        );
    }
}
const styles = StyleSheet.create({
    container: {
        display: 'flex',
        flex: 1,
        backgroundColor: '#efefef'
    }
});